// 
/**  
 * All rights Reserved, Designed By 视连时代(上海)信息科技有限公司
 * @Title:   ZCPageListApi.m 
 * @Package  DShop
 * @author:  赵隆杰     
 * @date:    2019/11/6 17:33
 * @Copyright: 2019 视连时代(上海)信息科技有限公司 All rights reserved. 
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目
 */

#import "ZCPageListApi.h"

@implementation ZCPageListApi

- (instancetype)init {
    self = [super init];
    if (self) {
        _pageSize = 10;
        _pageNum = 1;
    }
    
    return self;
}

//- (id)requestArgument {
//    return @{@"pageNum":@(self.pageNum), @"pageSize":@(self.pageSize), @"orderByField":@"open_time", @"isChoiceness":@1, @"ostype":@1};
//}

-(void)start
{
    [super start];
    _isMore = YES;
}
/*
 https://qpp-apis.7pa.com//serv/game/getGameList?current=1&size=50&orderByField=open_time&isChoiceness=1&ostype=1
 */

- (void)requestCompleteFilter
{
    [super requestCompleteFilter];
    if (self.success) {
        self.resArr = @[];
        if ([self.res isKindOfClass:[NSDictionary class]]) {
            NSDictionary *dict = self.res;
            if ([dict containsObjectForKey:@"total"]) {
                NSNumber *total = dict[@"total"];
                _isMore = (total.integerValue > self.pageNum * self.pageSize);
            }
            if ([dict containsObjectForKey:@"rows"]) {
                NSArray *list = dict[@"rows"];
                NSMutableArray *result = [NSMutableArray array];
                for (NSObject *obj in list) {
                    if (![obj isKindOfClass:[NSNull class]]) { // 接口可能会返nsnull
                        [result addObject:obj];
                    }
                }

                self.resArr = result;
            }
        }
        
    }
    
}



@end
